package ch.mzimmermann.sjes;

/**
 *
 * @author Martin Zimmermann
 */
public class Calculator {

    private EventHelper eventHelper = new EventHelper(this);

    public class Event {

        long result;

        public Event(long result) {
            this.result = result;
        }
    }

    public class AddEvent extends Event {

        public AddEvent(long result) {
            super(result);
        }
    }

    public class SubEvent extends Event {

        public SubEvent(long result) {
            super(result);
        }
    }

    public void unregisterReceiver(Object o) {
        eventHelper.unregisterReceiver(o);
    }

    public void registerReceiver(Object o) {
        eventHelper.registerReceiver(o);
    }

    public void add(long a, long b) {
        eventHelper.fireEvent(new AddEvent(a + b));
    }

    public void sub(long a, long b) {
        eventHelper.fireEvent(new SubEvent(a - b));
    }

    public void pass(long a) {
        eventHelper.fireEvent(new Event(a));
    }
}
